//
//  YJYBrowsersInterActiveAnimationTransition.m
//  BannerViewDemo
//
//  Created by BaizYi on 2018/11/5.
//  Copyright © 2018 BaizYi. All rights reserved.
//

#import "YJYBrowsersInterActiveAnimationTransition.h"
#import "YJYPictureBrowsersPushAnimation.h"
#import "YJYPictureBrowsersPopAnimation.h"
#import "YJYPictureBrowsersPercentDrivenInteractive.h"

@interface YJYBrowsersInterActiveAnimationTransition ()

@property(strong,nonatomic) YJYPictureBrowsersPushAnimation  *custonPush;
@property(strong,nonatomic) YJYPictureBrowsersPopAnimation  *custonPop;
@property(strong,nonatomic) YJYPictureBrowsersPercentDrivenInteractive  *percentInteractive;


@end

@implementation YJYBrowsersInterActiveAnimationTransition


-(id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{
    return self.custonPush;
}

-(id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{
    return self.custonPop;
}
//-(id<UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id<UIViewControllerAnimatedTransitioning>)animator{
//    return nil;
//}
-(id<UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id<UIViewControllerAnimatedTransitioning>)animator{
    if (self.transitionParamer.gestureRecognizer) {
        return self.percentInteractive;
    }else{
        return nil;
    }
}


-(YJYPictureBrowsersPercentDrivenInteractive *)percentInteractive{
    if (_percentInteractive == nil) {
        _percentInteractive = [[YJYPictureBrowsersPercentDrivenInteractive alloc]initWithTransitionParamer:self.transitionParamer];
    }
    return _percentInteractive;
}
-(YJYPictureBrowsersPushAnimation *)custonPush{
    if (_custonPush == nil) {
        _custonPush = [[YJYPictureBrowsersPushAnimation alloc]init];
    }
    return _custonPush;
}

-(void)setTransitionParamer:(YJYPictureBrowsersTransitionParamer *)transitionParamer{
    _transitionParamer = transitionParamer;
    self.custonPush.transitionParamer = transitionParamer;
    self.custonPop.transitionParamer = transitionParamer;
}
-(YJYPictureBrowsersPopAnimation *)custonPop{
    if (_custonPop == nil) {
        _custonPop = [[YJYPictureBrowsersPopAnimation alloc]init];
    }
    return _custonPop;
}

@end
